package com.danny.demo.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @ClassName: MyInvocationHandler
 * @Description: 定义一个处理器
 * @Author: zhangdong
 * @Date: Created in 15:26 2019/6/26
 * @Version:
 */
public class MyInvocationHandler implements InvocationHandler {
    Subject realSubject ;

    public MyInvocationHandler(Subject realSubject){
        this.realSubject  = realSubject;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("调用代理类....");
        String string = (String)method.invoke(realSubject,args);
        return string;
    }
}
